/**
 * Created by Mr.Xing on 2018/10/16.
 */
mini.parse();
var grid1 = mini.get("datagrid1");

function SetData(data) {
    if (data.action == "edit" && data.layoutMode == "表格布局"){

        var type = data.layoutMode;
        var layout = mini.get("layoutMode");
        layout.setValue(type);
        // $("#tableType").append("行：<input id='tableLine' type='text'/>");
        // $("#tableType").append("列：<input id='tableColumn' type='text'/>");

        var tableClassId = data.id;
        grid1.setUrl(ajaxUrl + "/classTable/findByTableId.do?tableClassId="+tableClassId);
        grid1.load();

    }else if(data.action == "edit" && data.layoutMode == "自由布局"){

        var type = data.layoutMode;
        var layout = mini.get("layoutMode");
        layout.setValue(type);
        var tableClassId = data.id;

        grid1.setUrl(ajaxUrl + "/classTable/findByTableId.do?tableClassId="+tableClassId);

        grid1.load();

    }else if (data.action == "new"){
        console.log('new');
    }
}
//确定按钮
function onTableOk() {
    var datagrid = mini.get("datagrid1");

    var layout = mini.get("layoutMode");
    var type = layout.getValue();

    var form = mini.get("datagrid1");
    var i = 1;
    var tableType = form.getSelecteds();
    // console.log(tableType);
    return tableType; //返回选中的数据给父组件

    // if (type == "表格布局") {
    //     var l = $("#tableLine").val();
    //     var c = $("#tableColumn").val();
    //
    //     $("#fromTable").append("<div id='tableForm' class='mini-datagrid' style='width:700px;height:280px;'allowCellEdit='true'allowCellSelect='true' >1 </div>")
    //
    // } else if (type == "自由布局") {
    //     var form = mini.get("datagrid1");
    //     var i = 1;
    //     var tableType = form.getSelecteds();
    //     // console.log(tableType);
    //     return tableType; //返回选中的数据给父组件
    // }
}

//确定按钮
function onOk(e) {
    CloseWindow("ok");
}
//取消按钮
function onCancel(e) {
    CloseWindow("cancel");
}

function CloseWindow(action) {

    if (window.CloseOwnerWindow)
        return window.CloseOwnerWindow(action);
    else
        window.close();
}
